var currentPage = 1;// 当前页
var pageSize = 10;// 每页条数
var ttname = "";

//翻页事件
$(function () {
    $("#selectPageSize").click(function(){
        if($(".select_ul2").css('display')=='none'){
            $(".select_ul2").show();
            $("#selectPageSize").find('i').removeClass("icon-angle-up");
            $("#selectPageSize").find('i').addClass("icon-angle-down");
        }else {
            $(".select_ul2").hide();
            $("#selectPageSize").find('i').removeClass("icon-angle-down");
            $("#selectPageSize").find('i').addClass("icon-angle-up");
        }
    });
    $(".select_ul2 li").click(function(){
        $("#select_page_ul").hide();
        $("#selectPageSize").find('i').removeClass("icon-angle-down");
        $("#selectPageSize").find('i').addClass("icon-angle-up");
        $("#selectPageSize1").html($(this).html());
        pageSize=parseInt($(this).html());
        currentPage = 1;
        $("#currentPage").html(currentPage);
        resetTableListShowFunction();
    });

})

/**
 * 翻页事件
 */
function changeCurrentPage(flag) {
    if (flag) {
        var totalPage = parseInt($("#totalPage").html());
        if ("first" == flag) {
            currentPage = 1;
        } else if ("end" == flag) {
            currentPage = totalPage;
        } else if ("last" == flag) {
            currentPage = currentPage - 1;
            if (currentPage < 1) {
                currentPage = 1;
            }
        } else if ("next" == flag) {
            currentPage = currentPage + 1;
            if (currentPage > totalPage) {
                currentPage = totalPage;
            }
        }
        // console.log("当前页："+currentPage);
        $("#currentPage").html(currentPage);
        resetTableListShowFunction();
    }
    // 按钮可用性设置（第一页时向前翻页不可用，最后一页时向后翻页不可用）
}

/** 更新分页控件的总行数和总页数 */
function refreshPageControls(recordcount, pagecount) {
    $("#totalSize").html(recordcount);
    $("#totalPage").html(pagecount);
}

/** 重置表格数据 （后续异常修改建议：将此方法迁移至表格所在页面，具体实现可以参考内容系统-班主任分配） */
function resetTableListShowFunction() {
    // var ymname = $(".layui-this").text();
    // console.info(ymname);
    console.info(ttname)
    if (ttname == "用户列表") {
        getData();
    }else if (ttname == "城市管理") {
        getData();
    }else if (ttname == "轮播图管理") {
        getData();
    }else if (ttname == "农家乐-商户类型") {
        getData();
    }else if (ttname == "农家乐-游玩类型") {
        getData();
    }else if (ttname == "景区-商户类型") {
        getData();
    }else if (ttname == "农家住宿信息" || ttname == "景区住宿信息") {
        getbusinessRoominfo();
    }else if (ttname == "农家美食信息" || ttname == "景区美食信息") {
        getbusinessFoodinfo();
    }else if (ttname == "农家评论信息" || ttname == "景区评论信息") {
        getbusinessDiscussinfo();
    }else if (ttname == "农家收藏信息" || ttname == "景区收藏信息") {
        getbusinessCollectinfo();
    }else if (ttname == "农家定制游信息" || ttname == "景区定制游信息" || ttname == "农家定制信息" || ttname == "景区定制信息") {
        getbusinessCustominfo();
    }else if(ttname == "景区娱乐项目"){
        getbusinessEntertainment();
    }else if(ttname == "评论农家记录"){
        getUserDiscussfarminfo();
    }else if(ttname == "评论景区记录"){
        getUserDiscussScenicinfo();
    }else if(ttname == "收藏农家记录"){
        getUserCollectfarminfo();
    }else if(ttname == "收藏景区记录"){
        getUserCollectScenicinfo();
    }else if(ttname == "用户定制信息"){
        getUserCustominfo();
    }

    else{
        getData();
    }



}

/* 左侧收缩 */
$(function () {
    $(".side_left_arrrw").click(function () {
        var left = $(".Container_left").offset().left;
        if (left == 0) {
            close_leftmenu();

        } else {
            openleftmenu();
        }
    });
});

